package com.yanqu.road.server.manger.activity.auto.send;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.UnionActivityConditionData;
import com.yanqu.road.entity.activity.UserActivityConditionData;
import com.yanqu.road.logic.bussiness.player.UserActivityBussiness;
import com.yanqu.road.logic.bussiness.player.activity.UserStrongholdBusiness;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class StrongholdAutoSend extends BaseAutoSendActivity {

    public StrongholdAutoSend(ActivityInfo activityInfo) {
        super(activityInfo);
    }

    @Override
    public void sendLocalUserRankReward() {

    }

    @Override
    public void sendLocalUnionRankReward() {

    }

    @Override
    protected boolean updateConditionData(UserActivityConditionData data) {
        return UserStrongholdBusiness.updateUserActivityConditionData(data);
    }

    public Map<Long, UserActivityConditionData> getUserActivityRankConditionData(int activityId, int conditionType) {
        Map<Long, UserActivityConditionData> conditionDataMap = UserStrongholdBusiness.getUserActivityConditionTypeDataMap(activityId, conditionType);
        return conditionDataMap;
    }


    @Override
    public void sendConditionReward() {

    }

    @Override
    public List<UserActivityConditionData> getNeedSendUserActivityConditionData() {
        List<UserActivityConditionData> dataList = new ArrayList<>();
        Map<Long, Map<Integer, List<UserActivityConditionData>>> activityConditionDataMap = UserStrongholdBusiness.getAllUserActivityConditionDataMap(activityInfo.getActivityId());
        for (Map<Integer, List<UserActivityConditionData>> map : activityConditionDataMap.values()) {
            for (List<UserActivityConditionData> list : map.values()) {
                for (UserActivityConditionData data : list) {
                    if (!data.isGetReward()) {
                        dataList.add(data);
                    }
                }
            }
        }
        return dataList;
    }

    @Override
    public Map<String, UnionActivityConditionData> getUnionActivityConditionData(int conditionType) {
        return UserActivityBussiness.getUnionActivityConditionDataMap(activityInfo.getActivityId(), conditionType);
    }

    @Override
    public void noticeCrossUserRank(){
        super.noticeCrossUserRankByCrossServer();
    }

    @Override
    public void noticeCrossUnionRank(){
        super.noticeCrossUnionRankByCrossServer();
    }
}
